<?php
/**
 * @file testCahche.php
 * @desc 
 *   测试DsCahce
 * 
 */

//echo DIRECTORY_SEPARATOR;


//var_dump( explode('/','/tmp/home/jdk/') );
//var_dump( rmdir('ddf.html') );
//echo time();
/**
 * 得到当前时间
 */
function getMicrotime() {
	list ($usec, $sec) = explode(" ", microtime());
	return ((float) $usec + (float) $sec);
}

$id = ".SELECT * FROM dasdsa_DSADSA / dsad .dsa\n\t";
$startTime = getMicrotime();
	$filename = 'ds_' . md5($id) . '.php';
$lastTime = getMicrotime();
$useTime = $lastTime - $startTime;
echo "md5: {$useTime}s.<br />\t\n"; 

$startTime = getMicrotime();
	$filename = 'ds_' . preg_replace("/[[:punct:]]|[[:space:]]/", '',  $id) . '.php';
$lastTime = getMicrotime();
$useTime = $lastTime - $startTime;
echo "preg_replace: {$useTime}s.<br />\t\n"; 







$f = false;
var_dump( empty($f) );
var_dump( preg_split('/\/|\\\/','/tmp/home/jdk/D:\temp\ABCDE\OH~',-1,PREG_SPLIT_NO_EMPTY) );




// 测试DsCache
echo "<br />\t\n 测试DsCache:<br />\t\n";
require_once 'DsCache.class.php';
$policy = array( 'cache_dir' => dirname(__FILE__).DIRECTORY_SEPARATOR.'tmp',
    'cache_subdir'=>time().'/'.'Google',
   'encoding_filename'=>false);
$DsCache = new DsCache($policy);
$data = array('FUCK GFW!', 'OH~~ MY GODAZ.');


if( $DsCache->get(".SELECT * FROM dasdsa_DSADSA / dsad .dsa\n\t") == false ){
	echo "dasdsadjiasj";
	$DsCache->set(time().".SELECT * FROM dasdsa_DSADSA / dsad .dsa\n\t",$data);
}
echo "<br />\t\nRemoveAll:<br />\t\n";
//$DsCache->remove(".SELECT * FROM dasdsa_DSADSA / dsad .dsa\n\t");
$DsCache->removeAll();


?>
